import sys
import re

n = int(sys.argv[1])
regex = "(?P<total>[0-9.]+) records sent, (?P<msg_per>[0-9.]+) records/sec \((?P<bytes_per>[0-9.]+) MB/sec\), (?P<avg_la>[0-9.]+) ms avg latency, (?P<max_la>[0-9.]+) ms max latency, (?P<p50_la>[0-9.]+) ms 50th, (?P<p95_la>[0-9.]+) ms 95th, (?P<p99_la>[0-9.]+) ms 99th, (?P<p999_la>[0-9.]+) ms 99.9th."
msg_per = bytes_per = avg_la = max_la = p50_la = p95_la = p99_la = p999_la = 0

for i in range(n):
    logname = "t{}.nohup.log".format(i+1)
    with open(logname, encoding="utf-8") as fd:
        target = fd.readlines()[-1]
        res = re.match(regex, target)
        msg_per += float(res.group("msg_per"))
        bytes_per += float(res.group("bytes_per"))
        avg_la += float(res.group("avg_la"))
        max_la += float(res.group("max_la"))
        p50_la += float(res.group("p50_la"))
        p95_la += float(res.group("p95_la"))
        p99_la += float(res.group("p99_la"))
        p999_la += float(res.group("p999_la"))

print(msg_per, bytes_per, avg_la/n, max_la/n, p50_la/n, p95_la/n, p99_la/n, p999_la/n)